package com.catmiw.wyz.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;

public class FileUtils {
	public static String getTextFile(String filename,String charset){
		StringWriter sb=new StringWriter();
		BufferedReader reader=null;
		File f=new File(filename);
		if (!f.exists())
			return sb.toString();
		try {
			reader=new BufferedReader(new InputStreamReader(new FileInputStream(f),charset));
			String str=null;
			while ((str=reader.readLine())!=null){
				sb.append(str).append(System.getProperty("line.separator"));
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return sb.toString();
	}
}
